package com.yunhe.authority.domain.authority;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.neo4j.ogm.annotation.*;
import org.neo4j.ogm.annotation.Id;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Relationship;

import java.io.Serializable;
import java.util.List;

/**
 * 角色对象
 * @desc 角色对象定义
 * @author liuronglei
 */
@ApiModel(value = "Role", description = "角色对象")
@NodeEntity
public class Role implements Comparable<Role>, Serializable {
    @ApiModelProperty(value = "角色ID")
    @Id
    @GeneratedValue
    private Long id;
    @ApiModelProperty(value = "角色名")
    private String name;
    @ApiModelProperty(value = "标题")
    private String title;
    @ApiModelProperty(value = "是否可用")
    private String activity = "1";
    @ApiModelProperty(value = "新增时间")
    private String createTime;
    @ApiModelProperty(value = "角色等级")
    private Integer level;
    @ApiModelProperty(value = "子角色", hidden = true)
//    @Relationship(type = "HAS_CHILD")
    private List<Role> children;

    @ApiModelProperty(value = "创建人名称")
    private String creator;

    @ApiModelProperty(value = "描述")
    private String description;

    @ApiModelProperty(value = "关联用户数量")
    private Long numberOfAssociatedUsers;

    private boolean initRole=false;

    public boolean isInitRole() {
        return initRole;
    }

    public void setInitRole(boolean initRole) {
        this.initRole = initRole;
    }

    @Override
    public int compareTo(Role o) {
        if (this.level == null) {
            return -1;
        } else if (o.getLevel() == null) {
            return 1;
        }
        return this.level.compareTo(o.getLevel());
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getActivity() {
        return activity;
    }

    public void setActivity(String activity) {
        this.activity = activity;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    public List<Role> getChildren() {
        return children;
    }

    public void setChildren(List<Role> children) {
        this.children = children;
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Long getNumberOfAssociatedUsers() {
        return numberOfAssociatedUsers;
    }

    public void setNumberOfAssociatedUsers(Long numberOfAssociatedUsers) {
        this.numberOfAssociatedUsers = numberOfAssociatedUsers;
    }
}
